package cn.glinks.liuhe.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.OnClick;
import cn.glinks.liuhe.R;
import cn.glinks.liuhe.app.AppConstant;
import cn.glinks.liuhe.base.BaseActivity;
import cn.glinks.liuhe.utils.ActTransAnimUtils;
import cn.glinks.liuhe.widget.timeline.TimeLineAdapter;
import cn.glinks.liuhe.widget.timeline.TimeLineModel;


/**
 * Des:测评结果页面
 *
 * @author MarsBlade of Cyh
 * @created 2017-03-21 14:43
 */
public class HistoryResultActivity extends BaseActivity {

    @BindView(R.id.iv_title)
    ImageView mTitleImageView;

    @BindView(R.id.tv_comment)
    TextView mCommentText;

    @BindView(R.id.tv_advice)
    TextView mAdviceText;

    @BindView(R.id.btn_exit)
    Button mBackButton;

    @Override
    public int getLayoutId() {
        return R.layout.activity_test_result;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        // 获取传递过来的信息
        Bundle bundle = this.getIntent().getExtras();
        TimeLineModel model = (TimeLineModel) bundle.getSerializable(AppConstant.BUNDLE_HISTORY_COMMENT);
        int type = bundle.getInt(AppConstant.BUNDLE_HISTORY_TYPE, TimeLineAdapter.TYPE_PERSON);
        // 设置为透明状态栏
        SetTranslanteBar();
        // 设置按钮文本
        mBackButton.setText("返回");
        // 判断历史测评的类型(个人历史测评 or 整体测评报告)
        if (type == TimeLineAdapter.TYPE_GROUP) {
            mAdviceText.setVisibility(View.GONE);
            mTitleImageView.setImageResource(R.drawable.ic_test_report);
        }
        // 获取测评结果缓存
        if (model != null) {
            mCommentText.setText(model.getComment());
            mAdviceText.setText(model.getAdvice());
        } else {
            mCommentText.setText("没有结果");
            mAdviceText.setText("没有结果");
        }
    }

    /*--------------------------------------------------------------------------------
     *                          点击事件接口实现
     ---------------------------------------------------------------------------------*/
    // 退出测评
    @OnClick(R.id.btn_exit)
    public void clickBack() {
        //返回
        ActTransAnimUtils.finishActionSlideLeftToRight(HistoryResultActivity.this);
    }

}
